home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / mui / MCC_Envelope.lha / MCC_Envelope / Developer / C / Examples / Envelope-Demo.c next >
Encoding:
C/C++ Source or Header  |  1999-06-19  |  5.1 KB  |  162 lines

  1. /*
  2.  *
  3.  * Envelope.mcc (c) Copyright 1999 by Jon Rocatis
  4.  *
  5.  * Example for Envelope.mcc
  6.  *
  7.  * Envelope-demo.c
  8.  *
  9.  */
  10.  
  11. /* SMAKE */
  12.  
  13. #include <clib/alib_protos.h>
  14. #include <clib/exec_protos.h>
  15. #include <clib/graphics_protos.h>
  16. #include <clib/utility_protos.h>
  17. #include <clib/muimaster_protos.h>
  18. #include <pragmas/muimaster_pragmas.h>
  19. #include <libraries/mui.h>
  20. #include <stdio.h>
  21. #include <proto/all.h>
  22.  
  23. #include <mui/envelope_mcc.h>
  24. #include "Envelope-Demo.rev"
  25.  
  26. #define DB / ## /
  27. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  28.  
  29. static char *vers_string  = __VSTRING;
  30. static char *vers_tag = __VERSTAG;
  31.  
  32. /*** externals ***/
  33. extern struct Library *SysBase;
  34.  
  35. /*** main ***/
  36. int main(int argc,char *argv[])
  37. {
  38.   Object *aptText[4];
  39.   Object *aptEnvelope[3];
  40.   EnvelopeUpdateData_t tEnvData;
  41.   struct Library *IntuitionBase;
  42.   int ret = RETURN_ERROR;
  43.  
  44.     if (IntuitionBase = OpenLibrary("intuition.library", 36))
  45.     {
  46.       struct Library *MUIMasterBase;
  47.  
  48.       if (MUIMasterBase = OpenLibrary(MUIMASTER_NAME, 13))
  49.       {
  50.         APTR app;
  51.         APTR ptWindow;
  52.                         
  53.         ULONG signals;
  54.         BOOL running = TRUE;
  55.  
  56.         app = ApplicationObject,
  57.                 MUIA_Application_Title      , "Envelope-Demo",
  58.                 MUIA_Application_Version    , vers_string,
  59.                 MUIA_Application_Copyright  , __VERSCR,
  60.                 MUIA_Application_Author     , "Jon Rocatis",
  61.                 MUIA_Application_Description, "Demonstrates the Envelope class.",
  62.                 MUIA_Application_Base       , "ENVELOPEDEMO",
  63.  
  64.                 SubWindow, ptWindow = WindowObject,
  65.                   MUIA_Window_Title, "EnvelopeClass",
  66.                   MUIA_Window_ID   , MAKE_ID('E','N','V','E'),
  67.                   WindowContents, VGroup,
  68.  
  69.                   /*** create an Envelope gadget ***/
  70.                   // TVA
  71.                   Child, TextObject, MUIA_Text_Contents, "Typical TVA Envelope:", End,
  72.                   Child, aptEnvelope[0] = EnvelopeObject, ButtonFrame, MUIA_Envelope_NoL4, TRUE, MUIA_Envelope_StartAtBottom, TRUE, End,
  73.                   Child, MUI_MakeObject(MUIO_HBar, 0),
  74.                                                 
  75.                   // TVF
  76.                   Child, TextObject, MUIA_Text_Contents, "Typical TVF Envelope:", End,
  77.                   Child, aptEnvelope[1] = EnvelopeObject, ButtonFrame, MUIA_Envelope_EndLine, TRUE, MUIA_Envelope_StartAtBottom, TRUE, End,
  78.                   Child, MUI_MakeObject(MUIO_HBar, 0),
  79.                                                 
  80.                   // Pitch
  81.                   Child, TextObject, MUIA_Text_Contents, "Typical Pitch Envelope:", End,
  82.                   Child, aptEnvelope[2] = EnvelopeObject, ButtonFrame, MUIA_Envelope_EndLine, TRUE, MUIA_Envelope_ZeroLine, TRUE, MUIA_Envelope_DisplayLevelAdjust, 64, MUIA_Envelope_MinLevel, 1, End,
  83.                   Child, HGroup,
  84.                     Child, aptText[0] = TextObject, TextFrame, End,
  85.                     Child, aptText[1] = TextObject, TextFrame, End,
  86.                     Child, aptText[2] = TextObject, TextFrame, End,
  87.                     Child, aptText[3] = TextObject, TextFrame, End,
  88.                   End,
  89.                 End,
  90.               End,
  91.             End;
  92.  
  93.         if (app)
  94.         {
  95.           /*** generate notifies ***/
  96.           DoMethod(ptWindow, MUIM_Notify, MUIA_Window_CloseRequest, TRUE,
  97.                    app, 2,
  98.                    MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
  99.  
  100.           // Attach some text gadgets to the pitch envelope so we can see the knob readouts
  101.           set(aptEnvelope[2], MUIA_Envelope_Text, aptText);
  102.  
  103.           // Set the knob data for one of the gadgets
  104.           tEnvData.atKnobs[0].nTime  = 10;
  105.           tEnvData.atKnobs[0].nLevel = 10;
  106.           tEnvData.atKnobs[1].nTime  = 30;
  107.           tEnvData.atKnobs[1].nLevel = 70;
  108.           tEnvData.atKnobs[2].nTime  = 90;
  109.           tEnvData.atKnobs[2].nLevel = 0;
  110.           tEnvData.atKnobs[3].nTime  = 50;
  111.           tEnvData.atKnobs[3].nLevel = 40;
  112.           DoMethod(aptEnvelope[1], MUIM_Envelope_SetKnobs, &tEnvData);
  113.  
  114.           /*** ready to open the ptWindow ... ***/
  115.           set(ptWindow, MUIA_Window_Open, TRUE);
  116.  
  117.           while (running)
  118.           {
  119.             switch (DoMethod(app,MUIM_Application_Input,&signals))
  120.             {
  121.               case MUIV_Application_ReturnID_Quit:
  122.                 running = FALSE;
  123.                 break;
  124.             }
  125.  
  126.             if (running && signals)
  127.               Wait(signals);
  128.           }
  129.  
  130.           set(ptWindow, MUIA_Window_Open, FALSE);
  131.  
  132.           /*** shutdown ***/
  133.           MUI_DisposeObject(app);      /* dispose all objects. */
  134.  
  135.           ret = RETURN_OK;
  136.         }
  137.         else
  138.         {
  139.           puts("Could not open application!");
  140.           ret = RETURN_FAIL;
  141.         }
  142.  
  143.         CloseLibrary(MUIMasterBase);
  144.       }
  145.       else
  146.       {
  147.         puts("Could not open muimaster.library v13!");
  148.         ret = RETURN_FAIL;
  149.       }
  150.  
  151.       CloseLibrary(IntuitionBase);
  152.     }
  153.     else
  154.     {
  155.       puts("Could not open intuition.library v36!");
  156.       ret = RETURN_FAIL;
  157.     }
  158.     
  159.     return ret;
  160. }
  161.  
  162.